function ServiceJeu(url) { 
    var _url; 
    var _xhr_object;
    
	// Init the communication with ajax
    this.init = function(){ 
		// Firefox
    	if (window.XMLHttpRequest)  
    		this._xhr_object = new XMLHttpRequest(); 
		// Internet Explorer	
    	else if (window.ActiveXObject)  
    		this._xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
    	
		return 1;
    };
	
	// Send request on the server
    this.env = function(type, url2, message){
    	console.log("Function : this.env");
    	var that = this;
    	this._xhr_object.open(type, this._url + url2, false); 
    	
		// modification the hearder http
		//this._xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
    	
		this._xhr_object.send(message);
    	
		if (this._xhr_object.readyState == 4){
			 if (this._xhr_object.status == 200){
				 console.log(this._xhr_object.responseXml);
			 }}
    	return 0;
    };
    
    //********************************** XML **********************************//
    // ========================= GET =======================
	// Return the address of the server
	this.getAddr = function()
    {
    	return this.env("GET","/",null);
    };
    
	// List of users
    this.getUsers = function(){
    	return this.env("GET","/users/",null);
    };
    
	// List the boards
    this.getBoards = function(){
    	return this.env("GET","/boards/",null);
    };
    
	// Moves
	this.getBoardPlay = function(baord){
    	return this.env("GET","/boards/" + board + "/",null);
    };
    
	// History of moves
    this.getBoardMoves = function(baord){
    	return this.env("GET","/boards/" + board + "/moves",null);
    };
	
	// ========================= POST =========================
	// Create an user
    this.postUsers = function(fullname, screenname, pass){
    	
    	var message = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
    	"<goimerir version=\"1.0\"><user_create>" +
    	"<fullname value=\"" + fullname + "\" />" +
    	"<screenname value=\"" + screenname + "\" />" +
    	"<password value=\"" + pass + "\" /></user_create></goimerir>";
    	 
    	return this.env("POST","/users/",message);
    	//return this.env("POST","/go/ajax.php",message);
    	
    };
    
	// New board
    this.postBoardsNew = function(name, owner, invite, size, ownerWhite){
    	
    	var message = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
    			"<goimerir version=\"1.0\"><create_board><name value=\"" + name + "\" />" +
    			"<owner value=\"" + owner +"\" /><invitee value=\""+ invite +"\" />" +
    			"<size value=\"" + size + "\" />" +
    			"<owner_white value=\"" + ownerWhite + "\" /></create_board></goimerir>";
		
    	return this.env("POST","/boards/",message);
    };
    
	// Invite a player
    this.postUsersJoin = function(user, boards){
    	
    	var message = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
    			"<goimerir version=\"1.0\">" +
	    		"<create_invite><board url=\"http://api.imerir.go/boards/" + boards + "\" />" +
	    		"</create_invite></goimerir>";
    	
    	return this.env("POST","/users/" + user + "/invites",message);
    };
    
	// Board request
    this.postBoardJoin = function(board, name){
    	
    	 var message = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
    	 		"<goimerir version=\"1.0\"><create_board_request>" +
				"<sender name=\"" + name + "\" /></create_board_request></goimerir>";
    	 
    	
    	return this.env("POST","/boards/" + board + "/requests/",message);
    };
    
	// Delete a board
    this.deleteBoard = function(baord){
    	return this.env("DELETE","/boards/" + board + "/",null);
    };
    
	// Moves
    this.postPlayMove = function(baord, x, y){
    	
     var message ="<?xml version=\"1.0\" encoding=\"utf-8\" ?><goimerir version=\"1.0\">" +
     		"<create_move><row value=\"" + x + "\" /><column value=\"" + y + "\" /></create_move></goimerir>";
		    	
		
    	return this.env("POST","/boards/" + board + "/moves/",null);
    };
    
    this._url = url; 
    this._xhr_object = null; 
} 